import { request } from '@/utils/request';
import type { Data, Tag, UserList, Upload } from './members.d';
import type { ApiRes } from '../../../types/Data';
/**
 * @description 获取所有成员
 * @returns
 */
export function getMembers (params: any) {
  return request<ApiRes<Data>>({
    url: '/ww_user/list/all',
    method: 'get',
    params,
  });
}
// 删除成员
export function delMembers (params: {}) {
  return request<ApiRes<string>>({
    url: '/ww_user/delete',
    method: 'post',
    params,
  });
}
// 新增和编辑成员
export function addMembers (data: any) {
  return request<ApiRes<string>>({
    url: '/ww_user/save',
    method: 'post',
    data,
  });
}
// 获取部门信息
export function getdepartment (params: {}) {
  return request<ApiRes<string>>({
    url: '/ww_depart/tree',
    method: 'get',
    params,
  });
}
// 获取所有标签
export function getTag (params: {}) {
  return request<ApiRes<Tag[]>>({
    url: '/ww_tag/allTags',
    method: 'get',
    params,
  });
}
// 获取用户详情信息
export function getUserDetail (params: {}) {
  return request<ApiRes<UserList>>({
    url: '/ww_user/view',
    method: 'get',
    params,
  });
}

// 人员头像上传
export function uploadAvatar (data: any, params: { tenantId: string }) {
  return request<ApiRes<Upload>>({
    url: '/file/upload',
    method: 'post',
    params,
    data,
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  });
}

/**
 增加管理员
 */
export function saveMange (params:  { userId: string }) {
  return request({
    url: '/ha_mange/save',
    method: 'get',
    params,
  });
}
/**
 * 移除管理员
 */
export function deleteMange (params: { userId: string } ) {
  return request({
    url: '/ha_mange/delete',
    method: 'get',
    params,
  });
}
